<?php
class logController extends accessController{
    public static function _right(){
        return array(
            array('网站管理',1),
            array('前台程序日志','member'),
            array('后台程序日志','admin'),
            array('清除php日志','clear_php_log'),
            array('清除mysql日志','clear_mysql_log'),
        );
    }
	public function __construct(){
		parent::__construct();
		$this->virtual_pjt=load_pjt(1);
	}
	
    public function admin(){
        $php='';
        $mysql='';
        $php_file=PROJECT_PATH.'runtime/error_log.php';
        if(file_exists($php_file)){
            $php=file_get_contents($php_file);
            $php=ltrim($php,'<?php exit;?>');
        }
        $mysql_file=PROJECT_PATH.'runtime/error_mysql_log.txt';
        if(file_exists($mysql_file)){
            $mysql=file_get_contents($mysql_file);
        }
        include($this->viewer_dir.'log/admin.php');
    }
	public function clear_php_log(){
		$which=$_GET['which'];
		switch($which){
			case 'admin':
			$file=PROJECT_PATH.'runtime/error_log.php';
			file_put_contents($file,'<?php exit;?>');
			break;
			case 'member':
			$file=$this->virtual_pjt['PROJECT_PATH'].'runtime/error_log.php';
			file_put_contents($file,'<?php exit;?>');
			break;
		}
		alert('完成');
		back();
	}
	public function clear_mysql_log(){
		$which=$_GET['which'];
		switch($which){
			case 'admin':
			$file=PROJECT_PATH.'runtime/error_mysql_log.txt';
			file_put_contents($file,'');
			break;
			case 'member':
			$file=$this->virtual_pjt['PROJECT_PATH'].'runtime/error_mysql_log.txt';
			file_put_contents($file,'');
			break;
		}
		alert('完成');
		back();
	}
    public function member(){
        $php='';
        $mysql='';
        $php_file=$this->virtual_pjt['PROJECT_PATH'].'runtime/error_log.php';
        if(file_exists($php_file)){
            $php=file_get_contents($php_file);
            $php=ltrim($php,'<?php exit;?>');
        }
        $mysql_file=$this->virtual_pjt['PROJECT_PATH'].'runtime/error_mysql_log.txt';
        if(file_exists($mysql_file)){
            $mysql=file_get_contents($mysql_file);
        }
        include($this->viewer_dir.'log/member.php');
    }
}